
***************BEGIN COMPUTING MOMENTS***************
use "$temp/nlsy_moment_data", clear
drop if hgc_final>20
gen coll_final = (hgc_final>=16)


set seed 1234

qui{
forval i = 1/1000{
	
	if mod(`i', 20)==0{
		noi di as result "`i'"
	}
	
	use "$temp/nlsy_moment_data", clear
	drop if hgc_final>20
	gen coll_final = (hgc_final>=16)
	bsample
	
	//preserve
	preserve
	keep if !parcoll
	collapse (mean) coll_final [fw=weight_17], by(parent_inc_quart ability)	
	ren parent_inc_ p
	sort p ability //import
	keep coll_final
	xpose, clear
	save "$temp/boot/attendance_noncoll_boot_`i'", replace
	restore
			
			
	preserve
	keep if parcoll
	collapse (mean) coll_final [fw=weight_17], by(parent_inc_quart ability)	
	ren parent_inc_ p
	sort p ability //import
	keep coll_final
	xpose, clear
	save "$temp/boot/attendance_coll_boot_`i'", replace
	restore
}
}

clear
forval i = 1/1000{
	append using "$temp/boot/attendance_noncoll_boot_`i'"
}
export delimited "$dir/Model/boot/attendance_noncoll_boot_sample.csv", replace novarn

clear
forval i = 1/1000{
	append using "$temp/boot/attendance_coll_boot_`i'"
}
export delimited "$dir/Model/boot/attendance_coll_boot_sample.csv", replace novarn